package com.beiing.tianshuai.tianshuai.mine.presenter;

import com.beiing.tianshuai.tianshuai.base.BasePresenter;
import com.beiing.tianshuai.tianshuai.entity.FeedBackBean;
import com.beiing.tianshuai.tianshuai.mine.model.FeedBackModel;
import com.beiing.tianshuai.tianshuai.mine.model.FeedBackModel.OnRequestListener;
import com.beiing.tianshuai.tianshuai.mine.model.FeedBackModelImpl;
import com.beiing.tianshuai.tianshuai.mine.view.FeedBackViewImpl;

import java.io.File;

/**
 * Created by Jinni on 2017/7/23 0023.
 */

public class FeedBackPresenter extends BasePresenter implements FeedBackPresenterImpl, OnRequestListener {

    private FeedBackViewImpl mFeedBackView;
    private FeedBackModelImpl mFeedBackModel;

    public FeedBackPresenter(FeedBackViewImpl feedBackView) {
        mFeedBackView = feedBackView;
        mFeedBackModel = new FeedBackModel(this);
    }

    @Override
    public void getFeedBackResult(String uid, String content, String name, String sType, File pic) {
        mFeedBackView.showProgress();
        mFeedBackModel.getFeedBackResult(uid, content, name, sType, pic);
    }

    @Override
    public void getFeedBackWithoutPicResult(String uid, String content, String name, String sType) {
        mFeedBackView.showProgress();
        mFeedBackModel.getFeedBackWithoutPicResult(uid, content, name, sType);
    }

    @Override
    public void onSuccess(FeedBackBean bean) {
        mFeedBackView.hideProgress();
        mFeedBackView.onRequestSuccess(bean);
    }

    @Override
    public void onError(Throwable e) {
        mFeedBackView.hideProgress();
        mFeedBackView.onRequestFailed(e);
    }
}
